import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:aliyun_plugin/aliyun_plugin.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> renzheng() async {
    String metaInfo;
    // Platform messages may fail, so we use a try/catch PlatformException.
    metaInfo = await AliyunPlugin.metaInfo;
    Map<String,dynamic> param = {'metaInfo':metaInfo};
    Response res = await Dio().get('http://192.168.1.113:1777/api/v1/aliyun/initFaceVerify',queryParameters: param);
    bool value = await AliyunPlugin.faceVerify(res.data['data']['ResultObject']['CertifyId']);
    print(value);
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Row(children: <Widget>[
            Text('测试'),
            FlatButton(child: Text('开始认证'),onPressed: (){
              renzheng();
            },)
          ],)
        ),
      ),
    );
  }
}
